package com.cheng.io.decorator;

/**
 * 执行耗时装饰者
 */
public class CloseableTimeDecorator extends CloseableDecorator{
    private final Closeable closeable;

    public CloseableTimeDecorator(Closeable closeable) {
        super(closeable);
        this.closeable = closeable;
    }

    @Override
    public void close() {
        long begin = System.currentTimeMillis();
        super.close();
        long end = System.currentTimeMillis();
        System.out.println(closeable.getClass().getSimpleName() + "执行了" + (end - begin) +"ms");
    }
}
